package SignInTime;

import javax.swing.*;
import javax.swing.plaf.nimbus.NimbusLookAndFeel;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MainSignWindow {
    public static void Show(){

        //登录窗口
        JFrame jFrame = new JFrame("AnimaNE --SignIn");

        //设置窗口大小
        jFrame.setSize(600, 400);

        //设置窗口显示在屏幕的中间
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();  //获取到屏幕尺寸
        int x = (int) ((screenSize.getWidth() - jFrame.getWidth()) / 2);   //居中位置就是：屏幕尺寸/2 - 窗口尺寸/2
        int y = (int) ((screenSize.getHeight() - jFrame.getHeight()) / 2);

        //设置窗口皮肤
        try {
            UIManager.setLookAndFeel(new NimbusLookAndFeel());
        } catch (UnsupportedLookAndFeelException e) {
            throw new RuntimeException(e);
        }

        //位置设置好了之后再展示出来
        jFrame.setLocation(x, y);

        //登录按钮
        Button signIn = new Button("Sign In");
        jFrame.add(signIn);

        signIn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                UserStatus.isSignIn = true;
                jFrame.dispose();
            }
        });

        jFrame.setVisible(true);

    }
}
